﻿<UserControl x:Class="SoGame.Views.GamePlayView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:me="clr-namespace:SoGame.ViewModels"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="600">
    <UserControl.Resources>
        <me:GamePlayViewModel x:Key="viewModel" />
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
        	<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>
        </ItemsPanelTemplate>
        <Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
        	<Setter Property="OverridesDefaultStyle" Value="True"/>
        	<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        	<Setter Property="MinHeight" Value="26"/>
        	<Setter Property="CaretBrush" Value="{DynamicResource MetroTextBoxCaret}" />
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type TextBox}">
        				<Border x:Name="Border" Background="{DynamicResource MetroTextBoxBg}" BorderBrush="{DynamicResource MetroTextBoxBg}" BorderThickness="1">
        					<Grid Height="19" Margin="2,0">
        						<Button HorizontalAlignment="Right" Style="{DynamicResource MetroPathButton}" Command="{Binding ElementName=LayoutRoot, Path=DataContext.SearchCommand}">
        							<Grid HorizontalAlignment="Right" Height="Auto" Width="21" Margin="0,-2,0,2">
        								<Ellipse HorizontalAlignment="Center" Width="10" Height="10" Stroke="{DynamicResource GrayBrush6}" StrokeThickness="1.5"/>
        								<Path Data="M2,11 L-2.5,19" HorizontalAlignment="Left" Height="10.056" Margin="3.177,0,0,-1.03" Stretch="Fill" Stroke="{DynamicResource GrayBrush6}" UseLayoutRounding="False" VerticalAlignment="Bottom" Width="5.5" StrokeThickness="3" RenderTransformOrigin="0.5,0.5">
        									<Path.RenderTransform>
        										<TransformGroup>
        											<ScaleTransform/>
        											<SkewTransform/>
        											<RotateTransform Angle="19.558"/>
        											<TranslateTransform/>
        										</TransformGroup>
        									</Path.RenderTransform>
        								</Path>
        							</Grid>
        						</Button>
        						<ScrollViewer Margin="0,0,23,0" FontSize="13" x:Name="PART_ContentHost" d:LayoutOverrides="Height" />
        					</Grid>
        				</Border>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsEnabled" Value="False">
        						<Setter TargetName="Border" Property="Opacity" Value="0.5"/>
        					</Trigger>
        					<Trigger Property="IsMouseOver" Value="True">
        						<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource MetroTextBoxBorderHover}"/>
        					</Trigger>
        					<Trigger Property="IsFocused" Value="True">
        						<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource MetroTextBoxBorderHover}"/>
        						<Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroTextBoxBgFocus}"/>
        					</Trigger>
        					<Trigger Property="Validation.HasError" Value="True">
        						<Setter Property="ToolTip" Value="{Binding (Validation.Errors)[0].ErrorContent, RelativeSource={RelativeSource Self}}" />
        						<Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroTextBoxErrorBg}" />
        						<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource MetroTextBoxErrorBg}" />
        					</Trigger>
        					<MultiTrigger>
        						<MultiTrigger.Conditions>
        							<Condition Property="Validation.HasError" Value="True" />
        							<Condition Property="IsMouseOver" Value="True" />
        						</MultiTrigger.Conditions>
        						<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource MetroTextBoxErrorBorder}"/>
        					</MultiTrigger>
        					<MultiTrigger>
        						<MultiTrigger.Conditions>
        							<Condition Property="Validation.HasError" Value="True" />
        							<Condition Property="IsFocused" Value="True" />
        						</MultiTrigger.Conditions>
        						<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource MetroTextBoxErrorBorder}"/>
        						<Setter TargetName="Border" Property="Background" Value="{DynamicResource MetroTextBoxBgFocus}"/>
        					</MultiTrigger>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        	<Setter Property="Validation.ErrorTemplate">
        		<Setter.Value>
        			<ControlTemplate>
        				<AdornedElementPlaceholder />
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        	<Setter Property="ContextMenu">
        		<Setter.Value>
        			<ContextMenu>
        				<MenuItem Header="Cut" Command="ApplicationCommands.Cut"/>
        				<MenuItem Header="Copy" Command="ApplicationCommands.Copy"/>
        				<MenuItem Header="Paste" Command="ApplicationCommands.Paste"/>
        			</ContextMenu>
        		</Setter.Value>
        	</Setter>
        </Style>
        <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
        	<Setter Property="Background" Value="Transparent"/>
        	<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        	<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        	<Setter Property="Padding" Value="2,0,0,0"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type ListBoxItem}">
        				<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
        					<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        				</Border>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsSelected" Value="true">
        						<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
        						<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
        					</Trigger>
        					<MultiTrigger>
        						<MultiTrigger.Conditions>
        							<Condition Property="IsSelected" Value="true"/>
        							<Condition Property="Selector.IsSelectionActive" Value="false"/>
        						</MultiTrigger.Conditions>
        						<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
        						<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        					</MultiTrigger>
        					<Trigger Property="IsEnabled" Value="false">
        						<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        					</Trigger>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource viewModel}}">
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width="0.3*"/>
    		<ColumnDefinition Width="0.7*"/>
    	</Grid.ColumnDefinitions>
        <ListBox ItemsSource="{Binding GamePlays}" SelectedItem="{Binding CurrentGamePlay, Mode=TwoWay}" BorderThickness="0,0,10,0" BorderBrush="{x:Null}" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}">
        	<ListBox.ItemTemplate>
        		<DataTemplate>
        			<Grid Margin="0,5">
        				<Grid.ColumnDefinitions>
        					<ColumnDefinition Width="Auto"/>
        					<ColumnDefinition Width="*"/>
        				</Grid.ColumnDefinitions>
        				<StackPanel d:LayoutOverrides="Width, Height" Grid.ColumnSpan="1" Grid.Column="1" Margin="2,-5,0,0" Grid.RowSpan="2">
        					<TextBlock Text="{Binding Game}" Style="{DynamicResource ItemTitle}" d:LayoutOverrides="Width"/>
        					<TextBlock Text="{Binding Score, StringFormat=Score: \{0\}}" Style="{DynamicResource ItemDescription}" Foreground="{DynamicResource HighlightBrush}"/>
        					<TextBlock Text="{Binding Date, StringFormat=dd/MM/yy à HH:mm}" Foreground="{DynamicResource LabelTextBrush}" VerticalAlignment="Top" Margin="0,0,-52,0" Style="{DynamicResource ItemDescription}"/>
        				</StackPanel>
        				<Grid Height="50" VerticalAlignment="Center" Width="50">
        					<Rectangle Grid.Column="0" Fill="{DynamicResource HighlightBrush}" HorizontalAlignment="Left" Stroke="{x:Null}" Width="50" Height="Auto" VerticalAlignment="Stretch"/>
        					<Image Source="{Binding Photo}" HorizontalAlignment="Stretch" Height="Auto" Width="Auto" VerticalAlignment="Stretch"/>
        				</Grid>
        			</Grid></DataTemplate>     	
			</ListBox.ItemTemplate>      
		</ListBox>
        <Grid x:Name="Infos" DataContext="{Binding CurrentGamePlay}" Grid.Column="1" Margin="0,0,0,-50">
        	<Grid.RowDefinitions>
        		<RowDefinition Height="Auto"/>
        		<RowDefinition Height="*"/>
        		<RowDefinition Height="Auto"/>
        	</Grid.RowDefinitions>
            <StackPanel x:Name="AttachPanel" Orientation="Horizontal">
                <Image Width="30" Source="/SoGame;component/Assets/Images/flag.png" Height="30"/>
        		<TextBlock TextWrapping="Wrap" d:LayoutOverrides="Height" Text="rattacher joueur" VerticalAlignment="Center" Margin="5,-15,0,0" FontSize="42.667" FontFamily="Segoe UI Light" Style="{DynamicResource MetroHeader}"/>
        	</StackPanel>
        	<Grid Grid.Row="1">
        		<Grid.ColumnDefinitions>
        			<ColumnDefinition Width="*"/>
        			<ColumnDefinition Width="*"/>     	
        		</Grid.ColumnDefinitions>
        		<Grid MinHeight="200" MinWidth="200">
        			<Rectangle>
        				<Rectangle.Fill>
        					<SolidColorBrush Color="{DynamicResource Gray4}" />
        				</Rectangle.Fill>
        			</Rectangle>
        			<Image Source="{Binding Photo}"/>
        			<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="photo kinect" VerticalAlignment="Center" Style="{DynamicResource MetroHeader1}" Foreground="{DynamicResource GrayBrush3}"/>
        		</Grid>
        		<Grid Grid.Column="1" Margin="12,0,0,0">
        			<Grid.RowDefinitions>
        				<RowDefinition Height="Auto"/>
        				<RowDefinition Height="Auto"/>
        				<RowDefinition Height="Auto"/>
        				<RowDefinition Height="Auto"/>
        				<RowDefinition Height="Auto"/>
        				<RowDefinition Height="*"/>
        			</Grid.RowDefinitions>
        			<TextBlock TextWrapping="Wrap" Text="{Binding Game}" d:LayoutOverrides="Width, Height" Style="{DynamicResource ItemTitle}"/>
        			<TextBlock TextWrapping="Wrap" Text="{Binding Score, StringFormat=Score: \{0\}}" d:LayoutOverrides="Width, Height" Style="{DynamicResource ItemTitle}" Grid.Row="1" Foreground="{DynamicResource HighlightBrush}"/>
        			<TextBlock TextWrapping="Wrap" Text="{Binding Date, StringFormat=dd/MM/yy à HH:mm}" d:LayoutOverrides="Width, Height" Style="{DynamicResource ItemDate}" Grid.Row="2"/>
        			<TextBlock TextWrapping="Wrap" Text="rattacher la partie à :" d:LayoutOverrides="Width, Height" Grid.Row="3" Style="{DynamicResource DefaultTextBlockStyle}"/>
        			<Grid x:Name="Joueur" DataContext="{Binding DataContext.CurrentPlayer, ElementName=LayoutRoot}" d:LayoutOverrides="Width, Height" Grid.Row="4">
        				<Grid.ColumnDefinitions>
        					<ColumnDefinition Width="Auto"/>
        					<ColumnDefinition Width="*"/>
        				</Grid.ColumnDefinitions>
        				<StackPanel d:LayoutOverrides="Width, Height" Grid.ColumnSpan="1" Grid.Column="1" Margin="2,-5,0,0" Grid.RowSpan="2">
        					<StackPanel Orientation="Horizontal">
        						<TextBlock Text="{Binding Name}" Style="{DynamicResource ItemTitle}"/>
        						<TextBlock Text="{Binding FirstName}" Style="{DynamicResource ItemTitle}" Margin="5,0,0,0"/>
        					</StackPanel>
        					<TextBlock Text="{Binding GamePlays.Count, StringFormat=\{0\} partie(s)}" Style="{DynamicResource ItemDescription}"/>
        					<TextBlock Text="{Binding Email}" Foreground="{DynamicResource LabelTextBrush}" VerticalAlignment="Top" Margin="0,0,-52,0" Style="{DynamicResource ItemDescription}"/>
        				</StackPanel>
        				<Grid Height="50" VerticalAlignment="Center" Width="50">
        					<Rectangle Grid.Column="0" Fill="{DynamicResource HighlightBrush}" HorizontalAlignment="Left" Stroke="{x:Null}" Width="50" Height="Auto" VerticalAlignment="Stretch"/>
        					<Image Source="{Binding Photo}" HorizontalAlignment="Stretch" Height="Auto" Width="Auto" VerticalAlignment="Stretch"/>
        				</Grid>
        			</Grid>
        			<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="5" d:LayoutOverrides="VerticalAlignment">
        				<Button Content="Enregistrer" Command="{Binding DataContext.SaveCommand, ElementName=LayoutRoot}" HorizontalAlignment="Center"/>
        				<Button Content="Annuler" Command="{Binding DataContext.CancelCommand, ElementName=LayoutRoot}" HorizontalAlignment="Center" Margin="5,0,0,0"/>
        			</StackPanel>
        		</Grid>
        	</Grid>
        	<Grid Grid.Row="2">
        		<Grid.RowDefinitions>
        			<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
        			<RowDefinition Height="*"/>
        		</Grid.RowDefinitions>
        		<TextBlock TextWrapping="Wrap" Text="joueurs" d:LayoutOverrides="Width, Height" Style="{DynamicResource MetroHeaderBold}"/>
                <TextBox TextWrapping="Wrap" GotFocus="TextBox_GotFocus" Text="{Binding DataContext.SearchText, ElementName=LayoutRoot, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource TextBoxStyle1}" Grid.Row="1" />
        		<ListBox ItemsSource="{Binding DataContext.Players, ElementName=LayoutRoot}" 
				SelectedItem="{Binding DataContext.CurrentPlayer, ElementName=LayoutRoot, Mode=TwoWay}"
				ItemsPanel="{DynamicResource ItemsPanelTemplate1}" Grid.Row="2">
        			<ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="0,5">
                    	<Grid.ColumnDefinitions>
                    		<ColumnDefinition Width="Auto"/>
                    		<ColumnDefinition Width="*"/>
                    	</Grid.ColumnDefinitions>
                    	<StackPanel d:LayoutOverrides="Width, Height" Grid.ColumnSpan="1" Grid.Column="1" Margin="2,-5,12,0" Grid.RowSpan="2">
                    		<StackPanel Orientation="Horizontal">
                    			<TextBlock Text="{Binding Name}" Style="{DynamicResource ItemTitle}"/>
                    			<TextBlock Text="{Binding FirstName}" Style="{DynamicResource ItemTitle}" Margin="5,0,0,0"/>
                    		</StackPanel>
                    		<TextBlock Text="{Binding GamePlays.Count, StringFormat=\{0\} partie(s)}" Style="{DynamicResource ItemDescription}"/>
                    		<TextBlock Text="{Binding Email}" Foreground="{DynamicResource LabelTextBrush}" VerticalAlignment="Top" Margin="0,0,-52,0" Style="{DynamicResource ItemDescription}"/>
                    	</StackPanel>
                		<Grid Height="50" VerticalAlignment="Center" Width="50">
                			<Rectangle Grid.Column="0" Fill="{DynamicResource HighlightBrush}" HorizontalAlignment="Left" Stroke="{x:Null}" Width="50" Height="Auto" VerticalAlignment="Stretch"/>
                			<Image Source="{Binding Photo}" HorizontalAlignment="Stretch" Height="Auto" Width="Auto" VerticalAlignment="Stretch"/>
                		</Grid>
                	</Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        		</ListBox>
        	</Grid>
        </Grid>
    </Grid>
</UserControl>
